package com.bicon.life.core.base.config;

import com.bicon.life.core.base.common.Constants;
import com.bicon.life.core.base.repository.redis.RedisTemplateUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.ApplicationListener;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.event.ContextRefreshedEvent;

/**
 * 应用启动监听
 */
@Configuration
public class RegisterServiceListener implements ApplicationListener<ContextRefreshedEvent> {


    @Value("${spring.application.name}")
    private String appName;

    @Autowired
    private RedisTemplateUtil redisTemplateUtil;

    @Override
    public void onApplicationEvent(ContextRefreshedEvent event) {
        redisTemplateUtil.cacheHash(Constants.REDIS_SERVICES_LIST_PRFIX,Constants.REDIS_SERVICES_LIST_KEY,appName,appName);
    }



}